home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 34 < prev    next >
Encoding:
Text File  |  1996-08-06  |  2.8 KB  |  58 lines

  1. Newsgroups: comp.lang.c++,comp.std.c++
  2. Path: cs.mu.OZ.AU!bounce-back
  3. From: jgalt@infosoft.com (John Galt)
  4. Subject: Re: Name-mangling standard
  5. Message-ID: <DL1pqE.KKq@infosoft.com>
  6. Followup-To: comp.lang.c++
  7. Originator: fjh@munta.cs.mu.OZ.AU
  8. Sender: news@cs.mu.OZ.AU (CS-Usenet)
  9. Organization: Infosoft Inc., Cupertino, CA, USA
  10. References: <20c.32169.607@newage.com.ar> <4bsnbu$5mu@mujibur.inmind.com> <30EDC013.7C780E5E@cims.nyu.edu>
  11. X-Original-Date: Fri, 12 Jan 1996 02: 03:49 GMT
  12. Date: Fri, 12 Jan 1996 03:58:32 GMT
  13. Approved: fjh@cs.mu.oz.au
  14. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  15.     iQBFAgUBMPXceOEDnX0m9pzZAQEYkQF9GMT9Br8Ri008HowMw3389GFa1XSEbtRl
  16.     14CQjOfZ9ZoP/fwM1yJaotwHmTMfk6nX
  17.     =aysm
  18.  
  19. > I certainly hope not!  Name mangling is a solution to passing type
  20. > information to 1950's linkers.  Once linkers become more sophisticated,
  21. > name mangling can disappear back into the slime from which it came.
  22.  
  23. I beg to differ.  Name mangling serves several indispensible functions:
  24.  
  25. 1.  It makes it possible to have more than one function with the same name
  26. (differing in their argument lists).  To do this without mangling, the linker
  27. would have to see not just a function name, or even class::name, but a full
  28. _prototype_ for each function (omitting variable names and the result type).
  29.  
  30. 2.  It allows the linker to do error checking.  Example:  Module A calls
  31. foo() in module B.  I change the definition of foo (and its argument list)
  32. but forget to change A.  Without name mangling, the program will simply crash
  33. (or do strange things because I've clobbered the stack...)
  34.  
  35. On systems like the PC, with multiple pointer formats, this could also be
  36. used to check that all modules (including library code) were compiled with
  37. the same (or compatible) memory model.  I think it is really stupid that none
  38. of the compilers for the PC makes this possible by including the memory model
  39. in mangled names.
  40.  
  41. 3.  When linking with other languages such as Pascal, it in effect checks that
  42. you told the C++ compiler to use the calling sequence for the language that
  43. the function you're calling is in.
  44.  
  45. In short, wanting to eliminate name mangling is like wanting a compiler that
  46. never prints error messages.  It's for people who would rather walk off a
  47. cliff than have someone tell them they're about to.
  48.  
  49. For the same reason, I'm against the concept of "undefined behavior" in the C
  50. and C++ standards.  No program that has "undefined behavior" should compile.
  51. --
  52. John David Galt                                I do not speak for my employer.
  53. jgalt@infosoft.com      Send personal mail to:  John_David_Galt@cup.portal.com
  54. ---
  55. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  56.   Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  57.   is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
  58.